<template>
  <div>
    <div class="welcome light-background">
      <div class="welcome-content">
        <span>您好！欢迎来到新创明远</span>
        <div class="phone">
          <span>服务热线：<span class="phoneNum">{{ getVal('LANDLINE') }}</span></span>
        </div>
      </div>
    </div>
    
    <div class="top">
      <el-row class="top-content" ref="row">
        <el-col :xs="24" :sm="12">
          <div class="title">
            <kinesis-container>
              <kinesis-element :strength="100" type="rotate"> 
                <img :class="titleType==2?'img2':''" src="@/assets/logo.png" alt="">
              </kinesis-element>
            </kinesis-container>
            <div class="top-right" :class="titleType==2?'title2':''">
              <span class="name">北京新创明远科技发展有限公司</span>
              <span class="english-name">Beijing Xinchuang Mingyuan Technology Co., Ltd</span>
            </div>
          </div>
        </el-col>
        <el-col class="menu-tab" :class="titleType==2?'tab2':''" :xs="24" :sm="12">
          <kinesis-container v-for="menu in menus" :key="menu.path">
            <kinesis-element :strength="0"> 
              <div class="menu-item" :class="$route.path.includes(menu.path)?'active':''" @click="$router.push(menu.path)">{{ menu.name }}</div>
            </kinesis-element>
          </kinesis-container>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menus:[],
      titleType:1
    };
  },
  computed:{
    params(){
      return this.$store.state.pubParams
    }
  },
  methods: {
    //获取菜单
    getMenu(){
      this.$apis.baseData.getMenu({}).then(res=>{
        this.menus=res.data.list
      })
    },
    getVal(name){
      for(let item of this.params){
        if(item.code==name){
          return item.value
        }
      }
      return ''
    },
    startWatchingWidth() {
        console.log('宽度:', this.$refs.row.$el.offsetWidth);
        if(this.$refs.row.$el.offsetWidth&&this.$refs.row.$el.offsetWidth<=768){
          this.titleType=2
        }
    },
  },
  mounted(){
    this.getMenu()
    this.startWatchingWidth()
  }
};
</script>

<style scoped lang="scss">
  .welcome{
    display: flex;
    justify-content: center;
    background: $color-main-primary;
    color: #fff;
    padding: 12px 4px;
    .welcome-content{
      display: flex;
      justify-content: space-between;
      width: $public-width;
      max-width: 100%;
    }
    .phone{
      user-select:text;
    }
    // .phone:hover{
    //   display: inline-block;
    //   animation: shake 0.3s; /* 抖动的持续时间 */
    //   animation-iteration-count: forwards; /* 动画重复次数 */
    // }
  }
  @keyframes shake {
    0% { transform: translateY(0);}
    20% { transform: translateY(1px);}
    40% { transform: translateY(-2px);}
    60% { transform: translateY(2px);}
    80% { transform: translateY(-1px);}
    100% { transform: translateY(0);}
  }
  .light-background {
    width: 100%;
    background-image: linear-gradient(135deg, #449CFE,#044691,#449CFE,#044691,#449CFE, #044691,#449CFE,);
    background-size: 400% 400%; /* 背景图大小 */
    animation: move-light 16s linear infinite;
  }
  @keyframes move-light {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }
  .top{
    padding: 10px 4px;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid $color-main-primary;
    .top-content{
      width: $public-width;
      max-width: 100%;
    }
    .title{
      display: flex;
      align-items: center;
      .top-right{
        margin-left: 10px;
        display: flex;
        flex-direction: column;
        font-size: 14px;
        // background-image: -webkit-linear-gradient(left,  #000,#000, #c9c9c9, #000, #000);  
        // color: transparent;  
        // background-clip: text;  
        // background-size: 300% 100%;  
        // animation: maskedAnimation 6s infinite linear;  
        .name{
          font-size: 22px;
          margin:0 0 6px 0;
          letter-spacing: 2px;
        }
      }
      .img2{
        width: 50px;
        height: 50px;
      }
      .title2{
        font-size: 12px;
        .name{
          font-size: 18px;
        }
      }
    }
    .menu-tab{
      display: flex;
      align-items: center;
      justify-content: end;
      margin-top: 8px;
      .menu-item{
        margin: 0 10px;
        font-size: 18px;
        cursor: pointer;
      }
      .menu-item:hover{
        color: $color-main-primary;
      }
    }
    .tab2{
      justify-content: start;
    }
  }
  @keyframes maskedAnimation {  
    0% {  
      background-position: 0 0;  
    }  
      
    100% {  
      background-position: -150% 0;  
    }  
  } 
  .active{
    color: $color-main-primary;
  }
</style>
